package com.onpositive.gamemaker.spriteeditor;

import java.util.ArrayList;
import java.util.List;

public class SpriteCategory implements Comparable
{
	public static final String DEFAULT_CATEGORY_NAME = "(default)";
	
	protected final String categoryName;
	protected List<SpriteDescriptor> descriptors = new ArrayList<SpriteDescriptor>();
	
	public SpriteCategory(String categoryName)
	{
		this.categoryName = categoryName;
	}
	
	public void addSprite(SpriteDescriptor descriptor)
	{
		descriptors.add(descriptor);
	}
	
	public void removeSprite(SpriteDescriptor descriptor)
	{
		descriptors.remove(descriptor);
	}
	
	public SpriteDescriptor[] getSpriteList()
	{
		return descriptors.toArray(new SpriteDescriptor[0]);
	}
	
	public int getSpriteCount()
	{
		return descriptors.size();
	}

	/**
	 * @return Category name (and it's id)
	 */
	public String getCategoryName()
	{
		return categoryName;
	}

	@Override
	public int compareTo(Object o)
	{
		if (o instanceof SpriteCategory)
			return categoryName.compareTo(((SpriteCategory) o).getCategoryName());
		return 0;
	}
}

